<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    #include("common/header.html")
    <link rel="stylesheet" href="/css/table.css"/>
</head>

<body>
<div class="admin-main">

    <blockquote class="layui-elem-quote">
        <a href="javascript:editInfo();" class="layui-btn layui-btn-small">
            <i class="layui-icon">&#xe608;</i> 修改信息
        </a>
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>个人资料</legend>
        <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">头像</label>
                <div class="layui-inline">
                    #if(!$info.headUrl)
                    <img src="/images/timg.jpg" height="200px" width="200px">
                    #else
                    <img src="$!info.headUrl" data-src="$!info.headUrl" height="200px" width="200px">
                    #end
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.nickname</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.sex</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">生日</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!date.format('yyyy-MM-dd',$!info.birthday)</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">个人简介</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.personalInfo</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">课程简介</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.courseInfo</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">省/市/区</label>
                <div class="layui-form-mid layui-word-aux">$!info.province-$!info.city-$!info.area</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学历</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.edu</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">第二学历</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.edu2</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单位</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.company</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职称</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.title</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">证书</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.cert</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">现任职务</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.duties</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">最高职务</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.duties</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">当前学习币</label>
                <div class="layui-input-block">
                    <div class="layui-form-mid layui-word-aux">$!info.money</div>
                </div>
            </div>
        </div>
    </fieldset>
</div>
</body>

<script type="text/javascript">

    var layer;
    var form;
    layui.use(['layer', 'form'], function () {
        layer = layui.layer;
        form = layui.form()
    });

    function editInfo() {
//        location.href = "/teacher/edit";
        layer.open({
            type: 2,
            title: '修改信息',
            shadeClose: true,
            shade: false,
            maxmin: true, //开启最大化最小化按钮
            area: ['850px', '400px'],
            content: '/teacher/edit',
            btn: ['确定', '取消'],
            yes: function (index, layero) {

                //询问框
                layer.confirm('确定修改?', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    var id = $info.id;
                    var body = layer.getChildFrame('body', index);
                    var headUrl = body.find("#imgUrl").attr("data-src");
                    var nickname = body.find("#nickname").val();
                    var sex = body.find("#sex").val();
                    var birthday = body.find("#birthday").val();
                    var province = body.find("#province option:selected").attr("data");
                    var city = body.find("#city option:selected").attr("data");
                    var area = body.find("#area option:selected").attr("data");
                    var personalInfo = body.find("#personalInfo").val();
                    var courseInfo = body.find("#courseInfo").val();
                    var edu = body.find("#edu").val();
                    var edu2 = body.find("#edu2").val();
                    var company = body.find("#company").val();
                    var title = body.find("#title").val();
                    var cert = body.find("#cert").val();
                    var duties = body.find("#duties").val();
                    var dutiesTop = body.find("#dutiesTop").val();

                    $.ajax({
                        url: "/teacher/",
                        type: "put",
                        dataType: "json",
                        data: {
                            "id": id,
                            "headUrl": headUrl,
                            "nickname": nickname,
                            "sex": sex,
                            "birthday": birthday,
                            "province": province,
                            "city": city,
                            "area": area,
                            "personalInfo": personalInfo,
                            "courseInfo": courseInfo,
                            "edu": edu,
                            "edu2": edu2,
                            "company": company,
                            "title": title,
                            "cert": cert,
                            "duties": duties,
                            "dutiesTop": dutiesTop
                        },
                        success: function (r) {
                            console.log(r);

                            if (r.code == -1) {
                                layer.msg(r.msg);
                                return;
                            }
                            layer.close(index);
                            layer.msg('修改成功!', {time: 1000}, function () {
                                location.reload();
                            });
                        }
                    });
                });
            }
        });
    }

</script>

</html>